//
//  YTSetVC.m
//  YUNT
//
//  Created by 梁炜东 on 2017/11/20.
//  Copyright © 2017年 梁炜东. All rights reserved.
//

#import "YTSetVC.h"
#import "YTSetCell.h"
#import "YTCameraVC.h"
#import "YTYunTaiVC.h"
#import "YTUniversalVC.h"

@interface YTSetVC ()
@property(nonatomic, strong)NSMutableArray *setNormalSource;
@end

@implementation YTSetVC

- (void)viewDidLoad
{
    [super viewDidLoad];
    [self.backBtn setTitle:Language(@"返回") forState:UIControlStateNormal];
    self.titleLabel.text = Language(@"设置");
    self.rightBtn.hidden = YES;
    [self p_addSubView];
    _setNormalSource = [NSMutableArray arrayWithArray:@[@[@"50", Language(@"相机")], @[@"51", Language(@"云台")], @[@"52", Language(@"通用")]]];
}
-(void)p_addSubView
{
    [self.myTableView registerClass:[YTSetCell class] forCellReuseIdentifier:@"YTSetCell"];
    [[UITableViewHeaderFooterView appearance] setTintColor:[UIColor clearColor]];//section header改变颜色
    //        _myTableView.tableFooterView = [[UIView alloc] init];
    self.myTableView .sectionHeaderHeight = 0;
    self.myTableView .sectionFooterHeight = 0;
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.setNormalSource.count;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 60;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{//group模式 默认的head为0
    return CGFLOAT_MIN;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    YTSetCell *cell = [tableView dequeueReusableCellWithIdentifier:@"YTSetCell" forIndexPath:indexPath];
    [cell configObject:self.setNormalSource[indexPath.row]];
    return cell;
}
//-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
//{
//    UIView *head = [[UIView alloc] init];
//    UIView *line = [[UIView alloc] init];
//    line.backgroundColor = YTColorAlpha(210, 210, 210, 0.3);
//    [head addSubview:line];
//    [head mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.leading.trailing.bottom.equalTo(head);
//        make.height.mas_equalTo(1);
//    }];
//    return head;
//}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.row == 0)
    {
        YTCameraVC *cameraVC = [[YTCameraVC alloc] initWithType:YTSysSetCameraType];
        [self.navigationController pushViewController:cameraVC animated:YES];
    }else if (indexPath.row == 1)
    {
        YTYunTaiVC *yunTaiVC = [[YTYunTaiVC alloc] initWithType:YTSysSetYunTaiType];
        [self.navigationController pushViewController:yunTaiVC animated:YES];
    }else if (indexPath.row == 2)
    {
        YTUniversalVC *universalVC = [[YTUniversalVC alloc] initWithType:YTSysSetUniversalType];
        [self.navigationController pushViewController:universalVC animated:YES];
    }
}
@end
